--- id: TASK-018 title: Minimal Alabaster syntax highlighting for code files status: "\U0001F7E6 Backlog" assignee: [] created_date: '2026-06-29 16:44' labels: - feature - release-2 dependencies: [] priority: medium ordinal: 18000 --- ## Description Makes glint usable as a quick-edit editor for code (not just markdown) so it can reasonably be set as $EDITOR. Alabaster philosophy: color only a few token types, leave the rest base. Three pieces: 1) File-type routing: the editor selects a scanner by the file's extension — .md/.markdown/.txt/none -> the existing markdown scanner; known code extensions (.go .py .js .ts .rs .c .h .java .rb .sh .lua .toml .yaml .json …) -> a code scanner. Add editor.SetLanguage/SetScanner; app sets it in Load() from filepath.Ext. 2) Code scanner via chroma (already a transitive dep through glamour — promote to direct). Use chroma's lexer-by-filename to tokenize, then map ONLY: String* -> string color (reuse Code, or a new String role); Comment* -> Comment (visible); Number/Literal -> Accent; Keyword/Name/Operator -> base Text; Punctuation -> Muted. Everything else base. Split the chroma token stream into per-line []Span; the concatenated span text must equal the raw line (markup-visible / display-only invariant, same as the markdown scanner). Handle multi-line tokens (block comments, multi-line strings). 3) Theme: reuse Code/Comment/Accent/Muted; optionally add a dedicated String role if strings should differ from inline-code green. Keep it minimal and calm (Alabaster), not a full IDE theme. Not the main code editor — just 'open, read okay, small change, save'. Verify cursor/selection/wrap still work over code (tabs/CJK width is TASK-005). ## Acceptance Criteria - [ ] #1 Code files (by extension) use a minimal code scanner; markdown/text keep the markdown scanner - [ ] #2 Only strings, comments, and numbers/constants are colored (Alabaster-minimal); keywords/identifiers stay base, punctuation dimmed - [ ] #3 Uses the chroma lexer already bundled via glamour; spans concatenate to the raw line (display-only invariant) - [ ] #4 Multi-line tokens (block comments, multi-line strings) handled across lines